<!--
 * @Description: 岗位信息 - 主页面
 * @Author: DHL
 * @Date: 2022-10-24 21:00:47
 * @LastEditors: DHL
 * @LastEditTime: 2022-11-22 17:47:28
-->
<template>
  <tw-layout @refresh="handleRefresh" @search="handleSearch" @reset="handleReset">
    <!-- 按钮组 -->
    <template #btns>
      <el-button
        class="item"
        type="danger"
        :loading="loadingByDel"
        :disabled="isSelectRows"
        v-auth="`POST-DEL-LOGIC-BATCH`"
        @click="handleDelete()"
      >
        <svg-icon iconClass="delete"></svg-icon>
        批量删除
      </el-button>

      <el-button class="item" type="primary" v-auth="`POST-ADD`" @click="handleOpenForm('add')">
        <svg-icon iconClass="plus"></svg-icon>
        新增
      </el-button>
    </template>

    <!-- 查询表单 -->
    <template #header>
      <el-form ref="searchFormRef" :model="searchForm" label-width="90px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="编码">
              <el-input v-model="searchForm.code" clearable placeholder="请输入编码"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="名称">
              <el-input v-model="searchForm.name" clearable placeholder="请输入名称"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="有效状态">
              <el-select v-model="searchForm.status" clearable placeholder="请选择有效状态">
                <tw-dic dicKey="VALID_STATUS"></tw-dic>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </template>

    <!-- 数据表格 -->
    <tw-table
      ref="tableRef"
      :loading="loading"
      :options="tableOptions"
      :events="tableEvents"
      :data="tableData"
      @search="searchList"
      exportExcelAuthKey="POST-EXPORTEXCEL"
      @exportExcel="handleExport"
    >
      <!-- 排序号 -->
      <template #postSeq="{ row }">
        <vxe-input
          v-model="row.postSeq"
          type="number"
          @blur="handleUpdateById(row)"
          @prevNumber="handleUpdateById(row)"
          @nextNumber="handleUpdateById(row)"
        ></vxe-input>
      </template>

      <template #action="{ row }">
        <el-button link type="warning" v-auth="`POST-EDIT`" @click="handleOpenForm('edit', row)">
          编辑
        </el-button>
        <el-button link type="danger" v-auth="`POST-DEL-LOGIC-BATCH`" @click="handleDelete(row)">
          删除
        </el-button>
      </template>
    </tw-table>

    <postForm ref="formRef" @refreshTableData="handleRefresh"></postForm>
  </tw-layout>
</template>

<script src="./useIndex.ts"></script>

<style scoped lang="scss"></style>
